package ui;

import java.awt.Component;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;

class ExitButton extends JButton implements MouseListener{
	private static final long serialVersionUID = 1L;
	
	public ExitButton() {
		setIcon(new ImageIcon(InterfaceSprite.getImage(InterfaceElement.EXIT_BUTTON)));
		setBorder(BorderFactory.createEmptyBorder());
		//setContentAreaFilled(false);
		addMouseListener(this);
		setAlignmentX(Component.CENTER_ALIGNMENT);
	}

	//button changes to highlighted when the mouse hovers over it
	public void mouseEntered(MouseEvent e) {
		setIcon(new ImageIcon(InterfaceSprite.getImage(InterfaceElement.EXIT_BUTTON_HIGHLIGHT)));
		//repaint();
	}
	
	//button changes to normal when the mouse leaves the button's area
	public void mouseExited(MouseEvent e) {
		setIcon(new ImageIcon(InterfaceSprite.getImage(InterfaceElement.EXIT_BUTTON)));
		//repaint();
	}

	//exits the program when released
	public void mouseReleased(MouseEvent e) {
		System.exit(0);
	}
	
	//not needed
	public void mouseClicked(MouseEvent e) {
	
	}
	public void mousePressed(MouseEvent e) {
	
	}
	
}
